f()
function f() {
    console.log(loginCustomer)
    if (loginCustomer==null||loginCustomer===""){
        alert("请去登录")
        location.href="http://localhost:8080/customer/login.jsp";
    }
}

//退出登录
$(".out-login").click(function () {
    $.ajax({
        type:"get",
        url: "../outLogin",
        success: function (result) {
            console.log("result:" + result);

            location.href = "http://localhost:8080/index.jsp";

        }

    })
})


getCustImg()
//得到照片url
function getCustImg() {
    $.ajax({
        type: "get",
        // contentType: "application/json",
        // data:
        //     `{"number":${number}}`
        // `{"numberPwd":${numberPwd}}`
        // ,
        // dataType: "json",
        url: "../getCustImg",
        success: function (result) {
             console.log("result:" + result);
            if (result===null||result===""){

            }else {
                var custImgUrl = document.getElementById("image");
                custImgUrl.src= result
                // console.log(custImgUrl)
            }

            // var pwd = result.data;
            // if (result.code === 200){
            //     if (pwd===numberPwd){
            //         location.href = "http://localhost:8080/index.jsp";
            //     }else {
            //         alert("账号或密码错误");
            //     }
            // }
            // else
            //     alert(result.data);
        }
    })
}


goHotelDetail()
function goHotelDetail() {
    console.log(hotelName)
    $.ajax({
        type:"post",
        contentType: "application/json",
        data:
            hotelName
        // `{"numberPwd":${numberPwd}}`
        ,
        dataType: "json",
        url: "../getByName",
        success: function (result) {
            console.log(result)

            var hotel = result.data

            var hotelName = hotel[0].hotelName
            var hotelCity = hotel[0].hotelCity
            var hotelArea = hotel[0].hotelArea
            var hotelAdress = hotel[0].hotelAdress
            var hotelAbstract = hotel[0].hotelAbstract
            var hotelScroe = hotel[0].hotelScroe
            var hotelBrand = hotel[0].hotelBrand

            var hotilHeader = document.querySelector(".hotil-header")
            var hotilDetail = document.querySelector(".hotil-detial-particular")
            var hotilScore = document.querySelector(".hotil-score")
            var hotilprice = document.querySelector(".order-detail-hotil-price")

            var newhotilHeader = "<span class=\"hotil-header-name\">" + hotelName + "</span>\n" +
                "            <span class=\"star-count\">\n" +
                "                        <i></i> <i></i> <i></i> <i></i> <i></i>\n" +
                "            </span>\n" +
                "            <span class=\"address-location\"><span class=\"address-hotelCity\">" + hotelCity + "</span>,\n" +
                "                <span class=\"address-hotelArea\">" + hotelArea + "</span>,\n" +
                "                <span class=\"address-hotelAdress\">"+ hotelAdress +"</span></span>"


            var newhotilDetail = "<span style=\"color: #003580;font-size: 15px;font-family: 'Adobe 黑体 Std R'\"><span>" + hotelCity + "</span>最热门住宿之一</span>\n" +
                "            <br><br>\n" +
                "            <p>" + hotelAbstract +"</p>\n" +
                "            <p>西安唐华华邑酒店于2010年11月23日开始在Booking.com上接受预订连锁酒店/品牌: " + hotelBrand + "华邑酒店及度假村</p>"

            var newhotilScore = "设施/服务适合情侣/夫妻入住 - 客人为双人住宿体验给出了"+ hotelScroe



            hotilHeader.innerHTML = newhotilHeader
            hotilDetail.innerHTML = newhotilDetail
            hotilScore.innerHTML = newhotilScore

        }
    })


}

goHotelRooms()
function goHotelRooms() {
    console.log("......." + hotelName)
    $.ajax({
        type:"post",
        contentType: "application/json",
        data:
        hotelName,
        dataType: "json",
        url: "../getRoomTypeById",
        success: function (result) {

            var rooms = result.data

            var ulEle = document.querySelector(".order-detail-ul")


            for (var i=0;i<rooms.length;i++){
                console.log(rooms[i])
                var typeName = rooms[i].typeName
                var typePrice = rooms[i].typePrice
                var peopleNum = rooms[i].other1



                var newLi = "<li>\n" +
                    "                    <div class=\"order-detail-hotil-type\"><span>"+ typeName +"</span></div>\n" +
                    "                    <div class=\"order-detail-hotil-kezhu\"><span>" + peopleNum +"</span></div>\n" +
                    "                    <div class=\"order-detail-hotil-price\"><span>" + typePrice +  "元</span></div>\n" +
                    "                    <div class=\"order-detail-hotil-orderKnown\"><span>免费取消 （入住前一天下午11:59之前）</span></div>\n" +
                    "                    <div class=\"order-detail-hotil-roomNum\">\n" +
                    "                        <span>\n" +
                    "                        <select>\n" +
                    "                            <option value='0'>0</option>\n" +
                    "                            <option value='1'>1</option>\n" +
                    "                            <option value='2'>2</option>\n" +
                    "                            <option value='3'>3</option>\n" +
                    "                        </select>\n" +
                    "                        </span>\n" +
                    "                    </div>\n" +
                    "                </li>"
                ulEle.innerHTML += newLi
            }

        }
    })
}
goRoomsPrice()
function goRoomsPrice(){

    $(".order-submit").click(function () {
        var lis = $(".order-detail-ul li")
        console.log(lis.length)
        var prices = 0.0
        for (var i=0;i<lis.length;i++){
            var li = lis[i]

            var price = parseFloat(li.childNodes[5].childNodes[0].innerText)

            var index = li.childNodes[9].getElementsByTagName("select")[0].selectedIndex;//获取当前选择项的索引.
            var roomNum = li.childNodes[9].getElementsByTagName("select")[0].options[index].value;//获取当前选择项的值.

            var price1 = parseFloat(price*roomNum)
            prices = prices + price1
        }

        $("body").on("click",".order-submit",function () {
            console.log(prices)
            var roomsPrices = JSON.stringify(prices)
            $.ajax({
                type:"post",
                contentType: "application/json",
                data: roomsPrices,
                dataType: "json",
                url: "../getSession1",
                success: function (result) {
                    if (result===null||result===""){
                        alert("请先登录")
                    }else {
                        location.href = "http://localhost:8080/customer/order.jsp?roomsPrices="+roomsPrices;
                    }
                }
            })
        })



    })
}















function ShowDiv(show_div,bg_div){
    document.getElementById(show_div).style.display='block';
    document.getElementById(bg_div).style.display='block' ;
    var bgdiv = document.getElementById(bg_div);
    bgdiv.style.width = document.body.scrollWidth;
// bgdiv.style.height = $(document).height();
    $("#"+bg_div).height($(document).height());
};
//关闭弹出层
function CloseDiv(show_div,bg_div)
{
    document.getElementById(show_div).style.display='none';
    document.getElementById(bg_div).style.display='none';
};